package gof.com.yew.interpreter;

public class InterpretDemo {
	
	//规则：Vicent 和 John 是男性
	public static Expression isMale() {
		Expression e1 = new TerminalExpression("Vicent");
		Expression e2 = new TerminalExpression("John");
		return new OrExpression(e1, e2);
	}
	
	//规则：Forry 是一个已婚的女性
	public static Expression isMarried() {
		Expression e1 = new TerminalExpression("Forry");
		Expression e2 = new TerminalExpression("Married");
		return new AndExpression(e1, e2);
	}
	
	public static void main(String[] args) {
		Expression isMale = isMale();
	      Expression isMarriedWoman = isMarried();
	      System.out.println("John is male? " + isMale.interpreter("John"));
	      System.out.println("Julie is a married women? "  + isMarriedWoman.interpreter("Married Julie"));
	}

}
